package com.jinwei.qunguanjia.common.exception;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j;

/**
 * 业务异常
 * @author yuanzs
 */
@EqualsAndHashCode(callSuper = true)
@Slf4j
@Data
public class ServiceException extends RuntimeException {

    private String code;
    private String msg;

    public ServiceException(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    void setMsg(String msg, Object... args) {
        if (args == null || args.length == 0) {
            this.msg = msg;
        }
        try {
            this.msg = String.format(msg, args);
        } catch (Exception e) {
            log.error("getMsg error:", e);
        }
    }
}
